# Maintainer: Rabindra Dhakal <contact@qaidvoid.dev>
pkgname=zls
pkgver=0.12.0
pkgrel=0
_knownfolders=a564f582122326328dad6b59209d070d57c4e6ae
_diffz=90353d401c59e2ca5ed0abe5444c29ad3d7489aa
_binned_allocator=6c3321e0969ff2463f8335da5601986cf2108690
pkgdesc="Zig Language Server"
url="https://github.com/zigtools/zls"
arch="aarch64 x86_64"
license="MIT"
depends="zig"
source="$pkgname-$pkgver.tar.gz::https://github.com/zigtools/zls/archive/refs/tags/$pkgver.tar.gz
	known-folders-$_knownfolders.tar.gz::https://github.com/ziglibs/known-folders/archive/$_knownfolders.tar.gz
	diffz-$_diffz.tar.gz::https://github.com/ziglibs/diffz/archive/$_diffz.tar.gz
	binned_allocator-$_binned_allocator::https://gist.github.com/antlilja/8372900fcc09e38d7b0b6bbaddad3904/archive/$_binned_allocator.tar.gz"

prepare() {
	default_prepare

	mkdir -p "$srcdir"/cache/p
	mv "$srcdir"/known-folders-$_knownfolders "$srcdir"/cache/p/122048992ca58a78318b6eba4f65c692564be5af3b30fbef50cd4abeda981b2e7fa5
	mv "$srcdir"/diffz-$_diffz "$srcdir"/cache/p/122089a8247a693cad53beb161bde6c30f71376cd4298798d45b32740c3581405864
	mv "$srcdir"/binned_allocator-$_binned_allocator "$srcdir"/cache/1220363c7e27b2d3f39de6ff6e90f9537a0634199860fea237a55ddb1e1717f5d6a5
}

build() {
	export ZIG_GLOBAL_CACHE_DIR="$srcdir"/cache
	zig build \
		-Dcpu=baseline \
		-Dtarget=native-linux.6.1 \
		-Doptimize=ReleaseSafe \
		-Dpie=true
}

check() {
	export ZIG_GLOBAL_CACHE_DIR="$srcdir"/cache
	zig build test \
		-Dcpu=baseline \
		-Dtarget=native-linux.6.1 \
		-Doptimize=ReleaseSafe \
		-Dpie=true
}

package() {
	install -Dm755 zig-out/bin/zls -t "$pkgdir"/usr/bin/
}

sha512sums="
d27653ae57c89f5fea03ecaaefa4c273a6a3694db24a1ebdf735c7ef0ca145e2d61c8f19d18bd5434659ac8ed0f5f715e6d15e4252db87ad89ac9402f580a860  zls-0.12.0.tar.gz
4aa0148e859fb9cb0bc816906dedd204f16ce3001f07f13ad688b1307036d2517373a5bc9184a9aa3634be51851658f4da9b4484718e089c6cc65a30c725fe00  known-folders-a564f582122326328dad6b59209d070d57c4e6ae.tar.gz
387ee728bdc96ba44e3a7a1974e109377f0ca8a4802198a3dc1d5160af682b9a8613309e105ab4f65e76fe1fae08b88463aa692f643e7d8cc03db4de2f94b847  diffz-90353d401c59e2ca5ed0abe5444c29ad3d7489aa.tar.gz
62c7ed619b7cda6ca197c13066c3b6320baa16ff0f8e48b6ed1dd6dde26fd9cd652c78b8e975a43055fc5fad8b014531f32d95efc878ed863cf2b80b06668897  binned_allocator-6c3321e0969ff2463f8335da5601986cf2108690
"
